package com.wujilee.shardingsphere.controller;

import com.wujilee.shardingsphere.common.ServiceResult;
import com.wujilee.shardingsphere.entity.EntityUser;
import com.wujilee.shardingsphere.service.impl.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * @author liwuji
 * @date 2024/5/20
 * @desc
 **/
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @PostMapping("/batch")
    public ServiceResult<Boolean> batchSaveUser() {
        List<EntityUser> entityUsers = new ArrayList<>(5000);
        return new ServiceResult<>(true);
    }


    @PostMapping()
    public ServiceResult<Boolean> saveUser(@RequestBody EntityUser entityUser) {
        userService.saveUser(entityUser);
        return new ServiceResult<>(true);
    }

    @GetMapping("")
    public ServiceResult<EntityUser> getUser(EntityUser entityUser) {
        return new ServiceResult<>(true,userService.getUserById(entityUser.getId()),"");
    }
}
